<%
	Session("FormName")=""
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<%
	bSuangay=request("TxtSuangay")
	if bSuangay="" then
		bSuangay=date()
	else
		if not isdate(bSuangay) then
			bSuangay=date()
		else
			bSuangay=cdate(SaveDate(bSuangay))
		end if
	end if	
	bSuangay=SaveDate(FormatDate(bsuangay))
	bThu=weekday(bSuangay)
	'Dua ra danh sach lich bat dau tu thu 2 cho toi 2 tuan lien tiep	
	if bThu=1 then
		bDate=cdate(bSuangay)-6
	else
		bDate=cDate(bSuangay)-(bThu-2)
	end if
	bDateEnd=cdate(bDate)+7
	bDateEnd=SaveDate(FormatDate(bDateEnd))
	bDate=SaveDate(FormatDate(bDate))
	Dim Mangngay(7)
	Dim MangNoidung(7)
	For i=1 to 7	
	MangNgay(i)=bDate
		strnoidung=""
		Set Rec=Server.CreateObject("ADODB.Recordset")
		Rec.CursorType=3
		Rec.CacheSize=5
		if Session("bLich")="TCUC" then
			sSQL="select * from lichcongtac where ngaythang='"& bDate &"' and madonvi='000000' order by thoigian,thoigiankt,noidung"
		else
			sSQL="select * from lichcongtac where ngaythang='"& bDate &"' and madonvi='"& Session("bMaDonVi") &"' order by thoigian,thoigiankt,noidung"
		end if
		Rec.Open sSQL,Conn
		do while not Rec.EOF		
			if Rec("thoigiankt")="" then
				if Rec("thoigian")="" then
					strnoidung=strnoidung + chr(13) + Rec("noidung")
				else
					strnoidung=strnoidung + chr(13) + Rec("thoigian") + " " + Rec("noidung")
				end if
			else
				if Rec("thoigian")="" then
					strnoidung=strnoidung + chr(13) + Rec("noidung")
				else
					strnoidung=strnoidung + chr(13) + Rec("thoigian") + " - " + Rec("thoigiankt") + " " + Rec("noidung")
				end if
			end if
			Rec.MoveNext
		loop
		Rec.close
		set Rec=nothing
		bDate=cDate(bDate)+1
		bDate=SaveDate(FormatDate(bDate))
		MangNoidung(i)=strnoidung
	Next	
	bDate=SaveDate(FormatDate(bDate))
%>
<!--#include file="..\jvfunction.inc"-->
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function frm_onsubmit() {
	if(!isDate(frm.TxtSuangay.value)){
		alert("Ngày không hợp lệ");
		frm.TxtSuangay.focus();
		return false;
	}
}

function window_onload() {
	timer = setTimeout("TimeOut()",900000);	
	frm.TxtSuangay.focus();
}

function TxtSuangay_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	frm.TxtSuangay.value=editdate(trim(str))
}
}
function TimeOut(){
	window.frm.target="mainbottom"
	window.frm.action="dsLich.asp?bComm=xem";
	window.frm.submit();
}
function Stop(){
clearTimeout(timer)
}
//-->
</SCRIPT>
</HEAD>
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<BODY style="Font-family:Arial" topmargin=0 leftmargin=0 LANGUAGE=javascript onload="return window_onload()">
<form method=post name=frm action="dsLich.asp?bComm=xem"  LANGUAGE=javascript onsubmit="return frm_onsubmit()">
<TABLE border=1 bgColor=#bdd5d0 cellPadding=0 cellSpacing=0 width="100%" height="100%">
<%
	For i=1 to 7		
		bThu=weekday(MangNgay(i))
		bViec=MangNoidung(i)
		bNgay=FormatDate(MangNgay(i))		
		if MangNgay(i)=bSuangay then
			Response.Write "<TR bgColor='#f8f9d9'>"
			if bThu=1 then				
				%>
				<TD width="15%"><p align=center><font face='Arial' color=red><a onmouseout="window.status=''; return true" onmouseover="window.status='Xem chi ti&#7871;t l&#7883;ch'; return true" href='frmchitiet.asp?bNgay=<%=bNgay%>&bThu=<%=bThu%>' target="_blank" title='Xem chi ti&#7871;t l&#7883;ch'>CN</a></font><br>
				<input type=text size=10 maxlength=10 title='B&#7841;n c&#243; th&#7875; xem l&#7883;ch v&#224;o ng&#224;y b&#7845;t k&#7923; b&#7857;ng c&#225;ch &#273;&#225;nh v&#224;o ng&#224;y b&#7841;n mu&#7889;n xem' name=TxtSuangay value="<%=bNgay%>" style='background-color:#f8f9d9;height:20'  LANGUAGE=javascript onkeyup="return TxtSuangay_onkeyup(this.value)" ></TD>
				<%
			else
				%>
				<TD width="15%"> <p align=center><a onmouseout="window.status=''; return true" onmouseover="window.status='Xem chi ti&#7871;t l&#7883;ch'; return true" href='frmchitiet.asp?bNgay=<%=bNgay%>&bThu=<%=bThu%>' target="_blank" title='Xem chi ti&#7871;t l&#7883;ch'><font face="Arial">
                Thứ<font face="Arial"> </font> <font face='Arial'><%=bThu%></font></a><br>
				<input type=text size=10 maxlength=10 title='B&#7841;n c&#243; th&#7875; xem l&#7883;ch v&#224;o ng&#224;y b&#7845;t k&#7923; b&#7857;ng c&#225;ch &#273;&#225;nh v&#224;o ng&#224;y b&#7841;n mu&#7889;n xem' name=TxtSuangay value="<%=bNgay%>" style='background-color:#f8f9d9;height:20' LANGUAGE=javascript onkeyup="return TxtSuangay_onkeyup(this.value)" ></TD>
				<%
			end if			
			%>
			<TD width="85%">
            <Textarea rows=3 Readonly style='padding: 0;border-style: solid; border-color:#f8f9d9;background-color: #f8f9d9;Font-Family:Arial;Font-Size:14;width:100%' id=textarea1 name=textarea1 cols="20"><%=bViec%></Textarea></TD>
		</TR>
	<% else
			Response.Write "<TR bgColor='#bdd5d0'>"
			if bThu=1 then				
				%>
				<TD width="15%"><p align=center><font face='Arial' color=red><a onmouseout="window.status=''; return true" onmouseover="window.status='Xem chi ti&#7871;t l&#7883;ch'; return true" href='frmchitiet.asp?bNgay=<%=bNgay%>&bThu=<%=bThu%>' target="_blank" title='Xem chi ti&#7871;t l&#7883;ch'>CN</a></font><br>(<%=bNgay%>)</TD>
				<%				
			else
				%>
				<TD width="15%"><p align=center><font face="Arial"><a onmouseout="window.status=''; return true" onmouseover="window.status='Xem chi ti&#7871;t l&#7883;ch'; return true" href='frmchitiet.asp?bNgay=<%=bNgay%>&bThu=<%=bThu%>' target="_blank" title='Xem chi ti&#7871;t l&#7883;ch'>
                Thứ </font><font face='Arial'><%=bThu%></a></font><br>(<%=bNgay%>)</TD>
				<%				
			end if
		%>
			<TD width="85%">
            <Textarea rows=2 Readonly style='padding: 0;border-style: solid; border-color:#bdd5d0;background-color: #bdd5d0;Font-Family:Arial;Font-Size:14;width:100%' id=textarea1 name=textarea1 cols="20"><%=bViec%></Textarea></TD>
	</TR>
	<% end if		
	next
%>
</TABLE>
 </Form>
<Script Language=vbscript Runat=server>
Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
End Function
Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
End Function
</Script>
</BODY>
</HTML>